<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head th:replace="top::html" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>专家匹配需求</title>
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<body class="fixed hold-transition skin-blue">
    <div class="wrapper">

        <div th:replace="tophtml::html"></div>
        <div th:replace="left::html"></div>

        <!-- 右边部分 -->
        <div class="content-wrapper">
            <section class="content-header">
                <h1>专家匹配需求<small></small></h1>
                <ol class="breadcrumb">
					<li><a href="/index"><i class="fa fa-dashboard"></i>用户中心</a></li>
					<li><a href="/person/findPersonList">专家管理</a></li>
					<li>
						<a th:href="@{'/person/mateDemandView?pid='+${person.pid}}">专家匹配需求</a>
		            </li>
				</ol>
            </section>
			
            <!-- 右边列表展示 -->
            <section class="content container-fluid">
				<form class="form-inline" th:action="@{/person/mateDemand}" method="get" id="from1">
					<input type="hidden" name="pageNo" id="pageNo"/> 
					<input type="hidden" name="personId" th:value="${person.pid}" />
					<div style="font-size: 16px;">
                    <div class="form-group">
						<label>专家姓名：</label> 
						<a th:href="@{/person/findPersonList(pid=${person.pid})}" th:text="${person.name}"></a>
						<a th:href="@{/person/findButtDetailsList(pid=${person.pid})}" style="font-weight: bolder;margin-left: 60px;">专家已匹配需求</a>
                    </div><br>
                    <div class="form-group">
						<label>所属领域：</label>
                        <span th:text="${person.researchField}"></span>
                    </div><br>
                    <div class="form-group">
						<label>专业领域：</label>
						<span th:title="${person.professionaField}" th:text="${not #strings.isEmpty(person.professionaField)} and ${#strings.length(person.professionaField)} > 100 ? ${#strings.substring(person.professionaField, 0, 100)}+'...' : ${person.professionaField}"></span>
                    </div>
                    </div>
					<hr style="height:1px;border:none;border-top:1px solid #a4b1c2;" />                   
					
					<div class="form-group">
                        <input placeholder="关键字检索..." style="margin-left: 3px;width: 300px; display: inline" type="text" class="form-control" name="searchKeyword" th:value="${param.searchKeyword}">
                    	<button type="submit" class="btn btn-primary" style="margin-left: 40px;">搜索</button>
						<!-- <button type="reset" style="margin-left: 40px;" class="btn btn-primary">重置</button> -->
						<input type="button" class="btn btn-primary" value="返回" onclick="window.history.go(-1)" style="margin-left: 40px;">
						<button type="button" class="btn btn-primary" id="demandDownLoad" style="margin-left: 40px;">下载</button>
                    </div>
                    <br/><br/>
                    <div class="form-group">
                        <label>所属领域</label>
                        <span th:each="rfd : ${researchFieldDictiontryList}" style="margin-left: 3px;">
                        	<label style="font-weight: lighter;">
                           		<input type="checkbox" name="researchField" th:value="${rfd.names}" th:text="${rfd.worth}" th:checked="${researchFieldArr != null ? #arrays.contains(researchFieldArr, rfd.names) : false}">
                            </label>
                        </span>
                        <span style="margin-left: 10px; color: red;">(可以多选)</span>
	                    
					</div>
                    <div>
                        <span class="from-group">
	                        <label>所属地区</label>
	                        <label style="font-weight: lighter;">
	                        	<input style="margin-left: 3px;" type="radio" name="domesticOrForeign" id="optionsRadios1" value="0" th:checked="${domesticOrForeign == 0}"> 国内
	                        </label>
	                        <label style="font-weight: lighter;">
	                        	<input style="margin-left: 15px;" type="radio" name="domesticOrForeign" id="optionsRadios2" value="1" th:checked="${domesticOrForeign == 1}"> 国外
	                        </label>
                        </span>
                        <span class="form-group form-country">
	                        <label style="margin-left: 40px;">国家</label>
	                        <select class="form-area" style="margin-left: 5px;width: 202px;height: 33px;border-color: silver;">
	                            <option value="-1">--选择国家--</option>
	                            <option th:each="list:${countryDictiontryList}" th:value="${list.pid}" th:text="${list.worth}" th:selected="${list.pid eq country}"></option>
	                        </select>
                        </span><br/>
                        <span class="form-group form-area">
                        	<label style="margin-left: 42px;">省</label>
	                        <select class="form-area" id="provinceId" style="margin-left: 2px;width: 202px;height: 33px;border-color: silver;">
	                            <option value="-1">--选择省--</option>
	                            <option th:each="list:${provinceDictiontryList}" th:value="${list.names}" th:text="${list.worth}" th:selected="${list.names eq province}"></option>
	                        </select>
                        </span>
                        <span class="form-group form-area">
                        	<label style="margin-left: 5px;">市</label>
	                        <select class="form-area" id="cityId" style="margin-left: 5px;width: 202px;height: 33px;border-color: silver;">
	                            <option value="-1">--选择市--</option>
	                            <option th:each="list:${cityDictiontryList}" th:value="${list.names}" th:text="${list.worth}" th:selected="${list.names eq city}"></option>
	                        </select>
                        </span>
                        <span class="form-group form-area">
                        	<label style="margin-left: 5px;">区</label>
	                        <select class="form-area" id="areaId" style="margin-left: 5px;width: 202px;height: 33px;border-color: silver;">
	                            <option value="-1">--选择区--</option>
	                            <option th:each="list:${areaDictiontryList}" th:value="${list.names}" th:text="${list.worth}" th:selected="${list.names eq area}"></option>
	                        </select>
                        </span>
                    </div>
				</form>
				<!-- 作为下载中的参数使用 -->
				<input type="hidden" id="personId" th:value="${person.pid}" class="form-control"/>
				<div class="box">
					<div class="box-header with-border">
						<h3 class="box-title">
							<button class="btn btn-primary" id="dosubmit">批量匹配</button>
						</h3>
					</div>
					<!-- /.box-header -->
					<div class="box-body">
						<table class="table table-bordered">
							<tbody>
								<tr>
									<th><input id="all" type="checkbox"/></th>
									<th>需求id</th>
									<th>需求名称</th>
                                    <th>需求类型</th>
                                    <th>需求状态</th>
                                    <th>需求联系人</th>
                                    <th>操作</th>
								</tr>
								<tr th:each="demand : ${pageInfo?.list}" th:class="${not #lists.isEmpty(buttedDemandIdList)} and ${#lists.contains(buttedDemandIdList, demand.demandId)} ? butt-gray">
									<td>
										<input type="checkbox" class="matched" th:disabled="${not #lists.isEmpty(buttedDemandIdList)} and ${#lists.contains(buttedDemandIdList, demand.demandId)} ? butt-gray" 
											   th:value="'demandId='+${demand.demandId}+'&demandNumber='+${#strings.replace(demand.demandNumber, 'D', '')}+'&demandName='+${demand.demandName}+
											   '&personId='+${person.pid}+'&expertNumber='+${person.expertNumber}+'&name='+${person.name}" />
									</td>
									<td title="查看需求详情">
                                        <a th:href="@{'/person/demandDetail?demandId='+${demand.demandId}}+'&personId='+${person.pid}" th:text="${demand.demandNumber}"></a>
                                    </td>
                                    <td th:text="${not #strings.isEmpty(demand.demandName)} and ${#strings.length(demand.demandName)} > 20 ? ${#strings.substring(demand.demandName, 0, 20)}+'...' : ${demand.demandName}" 
                            			th:title="${demand.demandName}">
                            		</td>
                                    <td th:text="${demand.demandType}"></td>
                                    <td th:text="${demand.demandStatus}"></td>
									<td>
										<a th:href="@{'/person/personDetails?pid='+${demand.demandContactId == null ? '' : demand.demandContactId}}" 
										   th:text="${demand.demandContactName == 'null' ? '' : demand.demandContactName}"></a>
									</td>
									<td>
										<a href="javascript:void(0);" th:class="${not #lists.contains(buttedDemandIdList, demand.demandId)} ? singleMatch">匹配</a>
									</td>
								</tr>
								<tr>
								<td><input id="all" type="checkbox" th:disabled="${not #lists.isEmpty(buttedDemandIdList)}" />  All  </td>
								<td><button class="btn btn-primary" id="dosubmit">批量匹配</button></td>
								</tr>
							</tbody>
						</table>
					</div>
					<div th:replace="page1::html"></div>
					<!-- 返回按钮 -->
					<div style="width:240px; height: 30px; position:fixed;left:727px;bottom:10px;">
						<a href="/person/findPersonList" class="btn btn-primary">返回主页面</a>
						<button style="margin-left: 30px;" type="button" class="btn btn-primary" onclick="window.history.go(-1)">返回上一级</button>
					</div>
				</div>
			</section>
        </div>

        <div th:replace="footer::html"></div>
        <div class="control-sidebar-bg"></div>
    </div>

    <!-- 引入js -->
	<div th:replace="bottom::html" ></div>

</body>
	<script type="text/javascript" th:inline="javascript">
		<!-- 正则表达式 -->
		matchButt([[@{/person/pipei}]]);
		
		$("a.singleMatch").one("click", function() {
        	$(this).closest("tr").find(":checkbox").prop("checked", true);
        	matching([[@{/person/pipei}]]);
        });
		
		//下载 
		$(document).on('click','#demandDownLoad',function(){
			var personId = $('#personId').val();
			window.location.href = '/person/demandDownLoad?personId='+personId;
		});
	</script>

</html>